define([
		'app/service/ConfigService'
        ], function (
      	ConfigService
    ) {

	var opt = {};
	
	return {


		directive_configInit: function(){

			var myDate = new Date();
    		$("#datetime-picker").datetimePicker({
		    	value: [myDate.getFullYear(), add0(myDate.getMonth()+1), add0(myDate.getDate()), add0(myDate.getHours()), add0(myDate.getMinutes())]
		  	});

		},
		directive_inputname: function(){


			$(".name_cover").click(function(){

				$.promptInput("请输入直播名称",$(".name").val(), function(value){
					//OK button
					$(".name").val(value);

				}, null,"text" , "");
			});

		},
		directive_inputfee: function(){

			$(".fee_cover").click(function(){

				$.promptInput("请输入场费用",$(".fee").val(), function(value){
					//OK button
					$(".fee").val(value);

				}, null,"tel" , "");
			});

		},
		directive_inputpwd: function(){


			$(".pwd_cover").click(function(){

				$.promptInput("请输入固定密码",$(".pwd").val(), function(value){
					//OK button
					$(".pwd").val(value);

				}, null,"password" , "");
			});
		},
		directive_createRoom: function(){

			$(".create-room").click(function(){

				var roomtype = $(".tab-link.active").data("type");
				var pwd = $(".pwd").val();
				var fee = $(".fee").val();
				var name = $(".name").val();
				var starttime = $(".starttime").val();
				var unionid = $.getHashUrlParam("unionid");
				var orgUuid = $(this).data("orguuid");

				if($.isNullStr(name)){
					$.toast("直播名称不能为空");
					return;
				}
				if($.isNullStr(starttime)){
					$.toast("直播时间不能为空");
					return;
				}
				if(roomtype == "2"){
					if($.isNullStr(pwd)){
						$.toast("固定密码不能为空");
						return;							
					}

				}
				if(roomtype == "3"){
					if(isNaN(parseInt(fee)) || parseInt(fee) < 1){
						$.toast("入场费用最少为1元");
						return;	
					}
				}

				$.processing("创建中...", 1);
				RoomService.createRoom(roomtype, pwd, fee, name, starttime,unionid,orgUuid, function(resp){
					
					$.hidePreloader();

					if(resp.status == "200"){

						var uuid = resp.result;
						var url = $.wjtBaseFront + "/room/"+uuid+"/manage?unionid=" + $.getHashUrlParam("unionid");
						$.redirectTo(url);

					}else{

						$.toast("您的网络连接不太稳定，请重试");
					}
					

				});



			});

		}
	};

});
